<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>PSdash - 简便的Linux主机监控面板</title>
        <link href="{{ url_for(".static", filename="css/bootstrap.min.css") }}" rel="stylesheet">
        <link href="{{ url_for(".static", filename="css/light.css") }}" rel="stylesheet">

      <!--  <script src="{{ url_for(".static", filename="js/echarts.min.js") }}"></script>
        <script src="{{ url_for(".static", filename="js/macarons.js") }}"></script>  -->
        <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
        <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
        <!--[if lt IE 9]>
          <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
          <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
        <![endif]-->
    </head>
    <body>
    
       <div id="psdash">
     <h3 class="text-center">主机监控面板</h3>

  <div class="container content"> 
  <div id="main-content">
  
   <table class="table table-striped table-condensed table-hover"> 
    <thead> 
     <tr> 
      <th>节点名</th> 
      <th>节点IP</th> 
      <th>OS</th> 
      <th>负载</th> 
      <th>在线时间</th> 
      <th>带宽</th> 
      <th>流量</th> 
      <th>CPU</th> 
      <th>内存</th> 
      <th>硬盘</th> 
      <th>SWAP</th> 
      <th>在线用户</th> 
      <th>详情</th> 
     </tr> 
    </thead> 

    
    <tbody id="servers"> 
     <!-- Servers here \o/ --> 
     	       {% for x in datas %}

<tr id="r0" data-toggle="collapse" data-target="#rt0" class="accordion-toggle even">
      <td id="name">{{x.name}}</td>
      <td id="ip">{{x.ip}}</td>
      <td id="os"><img src="/static/images/{{x.os if x.os else "others"}}.gif"></td>
      <td id="load">{{x.sysinfo.load_avg[0]}}, {{x.sysinfo.load_avg[1]}}, {{x.sysinfo.load_avg[2]}}</td>
      <td id="uptime">{{x.uptime}}</td>
      <td id="network">{{x.netifs.recv_rate|filesizeformat}} /s ↓<br>{{x.netifs.send_rate|filesizeformat}} /s ↑</td>
      <td id="traffic">{{x.netifs.bytes_recv|filesizeformat}} ↓<br>{{x.netifs.bytes_sent|filesizeformat}} ↑</td>
      <td id="cpu"><div class="progress progress-striped active"><div style="width: {{x.cpu.user+x.cpu.system}}%;" class="progress-bar {% if (x.cpu.user+x.cpu.system)>80 %}progress-bar-warning{% elif (x.cpu.user+x.cpu.system)>90 %}progress-bar-danger{% else %}progress-bar-success{% endif %}">{{x.cpu.user+x.cpu.system}}%</div></div></td>
      <td id="memory"><div class="progress progress-striped active"><div style="width: {{x.memory.percent if x.memory else 0}}%;" class="progress-bar {% if (100-x.cpu.idle)>80 %}progress-bar-warning{% elif (100-x.cpu.idle)>90 %}progress-bar-danger{% else %}progress-bar-success{% endif %}">{{x.memory.percent if x.memory else 0}}%</div></div></td>
      <td id="hdd"><div class="progress progress-striped active"><div style="width: {% if x.disks[0] %} {{x.disks[0].space_used_percent}}% {% endif %}%;" class="progress-bar {% if (100-x.cpu.idle)>80 %}progress-bar-warning{% elif (100-x.cpu.idle)>90 %}progress-bar-danger{% else %}progress-bar-success{% endif %}">{%if x.disks[0]%} {{x.disks[0].space_used_percent}}% {%endif%}%</div></div></td>
      <td id="swap"><div class="progress progress-striped active"><div style="width: {{x.swap.percent if x.swap else 0}}%;" class="progress-bar progress-bar-success">{{x.swap.percent if x.swap else 0}}%</div></div></td>
      <td id="users">{{x.users|count}}</td>
      <td id="detail"><a href="{{url_for('.index',node=x.ip)}}"><img width="16" height="16" src="{{ url_for(".static", filename="images/arrow_right.png") }}"></a></td>
     </tr>
     {% endfor %}
    </tbody> 
   </table> 
   <br /> 
   <div id="updated">
    最后更新： {{updatetime}}
   </div> 
  </div>

  
</div>


   <script src="{{ url_for(".static", filename="js/jquery.min.js") }}"></script>
	<script>
	setInterval(function() {
	  $("#main-content").load(location.href+" #main-content>*","");
	}, 3000);
	</script>
   

    </body>
</html>
